package com.liu.dao.impl;

import com.liu.dao.IChapterDao;
import com.liu.pojo.Chapter;
import com.liu.util.LoggerFactory;

import java.sql.SQLException;
import java.sql.Types;
import java.util.List;

/**
 * @Author 老刘Matthew
 * @Timestamp 2022/7/24 22:02
 * @Description
 */
public class ChapterDaoImpl extends GenericDaoImpl<Chapter> implements IChapterDao, LoggerFactory {

    @Override
    public Integer save(Chapter o) throws SQLException {

        String sql =    //
                "insert into " +
                        "chapter(novel_id, title, content, read_count, push_time, sort) " +
                        "values (?, ?, ?, ?, ?, ?)";

        return jdbcTemplate.updateOrInsert(sql,
                new Object[]{
                        o.getNovel_id(),
                        o.getTitle(),
                        o.getContent(),
                        o.getRead_count(),
                        o.getPush_time(),
                        o.getSort()
                }, new Integer[]{
                        Types.INTEGER,  //
                        Types.VARCHAR,
                        Types.VARCHAR,
                        Types.INTEGER,
                        Types.TIMESTAMP,
                        Types.INTEGER
                });
    }

    @Override
    public Integer update(Chapter chapter) throws SQLException {
        return null;
    }

    @Override
    public List<Chapter> query(String where) throws SQLException {
        return null;
    }

    @Override
    public List<Chapter> queryAll() throws SQLException {
        return null;
    }

    @Override
    public Chapter querySingle(Integer id) throws SQLException {
        return null;
    }

    @Override
    public Integer queryCount(String table, String where) throws SQLException {
        return null;
    }


}
